package com.ry.demo.concurrent.demo;

/**
 * @Author: lihui
 * @Date: 2021-12-03 22:11
 * @Description:
 */
public class ThreadUnsafeDemo {

    private static int data = 0;

    public static void main(String[] args) throws InterruptedException {

        Thread thread1 = new Thread(() -> {

            for (int k = 0; k < 100; k++) {
                data++;
            }

        });

        Thread thread2 = new Thread(() -> {

            for (int k = 0; k < 100; k++) {
                data++;
            }

        });

        thread1.start();
        thread2.start();
//        thread1.join();
//        thread2.join();
//        thread3.join();

        Thread.sleep(1000);
        System.out.println(data);


    }
}
